package controller;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class TrafficController
 */
public class TrafficController extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public TrafficController() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String latLng = request.getParameter("latLng");
		String strategy = request.getParameter("strategy");
		String avoidTolls = request.getParameter("avoidTolls")!=null? "yes" : "no";
		System.out.println(latLng);
		System.out.println(strategy);
		System.out.println("Avoid Toll : "+avoidTolls);
		
		request.setAttribute("latLng", latLng);
		request.setAttribute("strategy", strategy);
		request.setAttribute("avoidTolls", avoidTolls);
		RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/showTraffic.jsp");
		dispatcher.forward(request,response);
	}

}
